package Util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import Model.Course;
import Model.Score;
import Model.Student;
import Model.queryclass;

public class PrintUtil {
	/**
	 * 打印学生列表
	 * 
	 * @param studentList
	 */
	public static void print(ArrayList<Student> studentList) {
		if (studentList == null || studentList.size() == 0) {
			System.out.println("学生列表为空");
			return;
		}

		System.out.print("ID     姓名         年龄       班级        专业          班级编号\n");
		for (int i = 0; i < studentList.size(); i++) {
			Student student = studentList.get(i);
			// 输出每一个数据
			System.out.print(student.getId() + "   ");
			System.out.print(student.getName() + "        ");
			System.out.print(student.getAge() + "   ");
			System.out.print(student.getClassname() + "    ");
			System.out.print(student.getMajor() + "             ");
			System.out.print(student.getClassid());
			System.out.print("\n");
		}

	}

	/**
	 * 打印班级信息
	 */
	public static void displayclass(ArrayList<queryclass> classList) {
		// TODO Auto-generated method stub
		if (classList == null || classList.size() == 0) {
			System.out.println("班级列表为空");
			return;
		}

		System.out.print("班级编号       班级名称         班级年级          专业\n");

		for (int i = 0; i < classList.size(); i++) {
			queryclass queryclass = classList.get(i);
			// 输出每一个数据
			System.out.print(queryclass.getClassid() + "          ");
			System.out.print(queryclass.getClassname() + "          ");
			System.out.print(queryclass.getYear() + "          ");
			System.out.print(queryclass.getMajor());

			System.out.print("\n");
		}
	}

	/**
	 * 打印成绩信息
	 */
	public static void displayscore(ArrayList<Score> scoreList) {
		// TODO Auto-generated method stub
		if (scoreList == null || scoreList.size() == 0) {
			System.out.println("成绩列表为空");
			return;
		}

		System.out.print("姓名                学号                  课程名           课程号          班级编号            分数\n");

		for (int i = 0; i < scoreList.size(); i++) {
			Score Score = scoreList.get(i);
			// 输出每一个数据
			System.out.print(Score.getName() + "            ");
			System.out.print(Score.getId() + "       ");
			System.out.print(Score.getCoursename() + "          ");
			System.out.print(Score.getCourseid() + "          ");
			System.out.print(Score.getClassid() + "          ");
			System.out.print(Score.getScore());

			System.out.print("\n");
		}
	}

	/**
	 * 打印菜单
	 */
	public static void printMenu() {
		System.out.println("——————————————学生信息管理系统—————————————");
		System.out.println("************请输入您想操作的信息编号 *******");
		System.out.println("***************1.查看学生基本信息表 ********");
		System.out.println("***************2.查看班级信息表************");
		System.out.println("***************3.查看学生成绩表************");
		System.out.println("***************4.查看课程信息表************");
		System.out.println("***************5.增添学生******************");
		System.out.println("***************6.删除学生******************");
		System.out.println("***************7.增添课程******************");
		System.out.println("***************8.删除课程******************");
		System.out.println("***************9.增添成绩******************");
		System.out.println("***************10.删除成绩*****************");
		System.out.println("***************11.增添班级*****************");
		System.out.println("***************12.删除班级*****************");
		System.out.println("***************13.修改学生信息*************");
		System.out.println("***************14.修改课程信息*************");
		System.out.println("***************15.修改班级信息*************");
		System.out.println("***************16.修改成绩信息*************");
		System.out.println("***************17.选课 ********************");
		System.out.println("***************18.查询选课信息*************");
		System.out.println("***************19.课程成绩排名*************");
		System.out.println("***************20.成绩分析 ****************");
		System.out.println("***************21.退出系统 ****************");
		System.out.println("———————————————————————————————————————————");
	}

	/**
	 * 打印课程信息
	 */
	public static void displayCourse(ArrayList<Course> CourseList) {
		// TODO Auto-generated method stub
		if (CourseList == null || CourseList.size() == 0) {
			System.out.println("课程列表为空");
			return;
		}

		System.out.print("课程号                课程名 \n");

		for (int i = 0; i < CourseList.size(); i++) {
			Course Course = CourseList.get(i);
			// 输出每一个数据
			System.out.print(Course.getCourseid() + "       ");
			System.out.print(Course.getCoursename());

			System.out.print("\n");
		}
	}

	public static void displayScoreSort(ArrayList<Score> scoreList) {
		if (scoreList == null || scoreList.size() == 0) {
			System.out.println("成绩列表为空");
			return;
		}

		System.out.print("排名         姓名                  课程名             分数\n");

		for (int i = 0; i < scoreList.size(); i++) {
			Score score = scoreList.get(i);
			// 输出每一个数据
			System.out.print(i + 1 + "       ");
			System.out.print(score.getName() + "          ");
			System.out.print(score.getCoursename() + "          ");
			System.out.print(score.getScore() + "          ");
			System.out.print("\n");
		}
	}

	public static void displayDetail(List<Map<String, Object>> mapList) {
		if (mapList == null || mapList.size() == 0) {
			System.out.println("没有查到相关数据");
			return;
		}

		System.out.print("      课程名          最高分             最低分             平均分        不及格人数\n");
		for (int i = 0; i < mapList.size(); i++) {
			Map<String, Object> map = new HashMap<String, Object>();
			// 输出每数据
			System.out.print(mapList.get(i).get("Coursename") + "          ");
			System.out.print(mapList.get(i).get("maxScore") + "          ");
			System.out.print(mapList.get(i).get("minScore") + "          ");
			System.out.print(mapList.get(i).get("avgScore") + "          ");
			System.out.print(mapList.get(i).get("failCount") + "          ");
			System.out.print("\n");
		}
	}

}
